home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / MBLIB10.ZIP;1 / CPPEXAMP.ZIP / SCNMAIL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  2.6 KB  |  103 lines

  1. /* WARNING: THIS EXAMPLE IS QUICK & DIRTY!!! Its only purpose is to         */
  2. /* demonstrate how certain MB_lib functions are used and how they work.     */
  3. /* While the code is a functional program, no attempt has been made to      */
  4. /* clean up the code or to streamline it, and I've economized a bit on      */
  5. /* error checking since I've made this in a hurry. However, if you're       */
  6. /* able to use MB_lib, odds are that you also know how to write neat code.  */
  7.  
  8. /* Scan mail to a certain user, first forward, then reverse */
  9.  
  10. #include    <string.h>
  11. #include    <stdlib.h>
  12. #include    <iostream.h>
  13.  
  14. #include    "msgbase.hpp"
  15.  
  16.  
  17. void main (void)
  18.  
  19. {
  20.     int                nmsgs;
  21.     long             recnr;
  22.     MSGTOIDX_RECORD    to;
  23.     MsgBase            Message ("C:\\MSGBASE");
  24.  
  25.  
  26.     if (!Message.ErrorType)
  27.     {
  28. //        cout << "User name? ";
  29. //        cin.getline (to, sizeof(to) - 1, '\n');
  30.         strcpy (to, "Frank van.Wensveen");
  31.  
  32.         cout << "\n\nListing forward...\n";
  33.  
  34.         recnr = Message.FirstTo (&to);
  35.         if (Message.ErrorType)
  36.         {
  37.             cerr << "Error: " << Message.ErrorType << ", "
  38.                  << Message.ErrorString << ".\n";
  39.         }
  40.  
  41.         nmsgs = 0;
  42.         while (recnr != -1)
  43.         {
  44.             nmsgs++;
  45.             Message.ReadHdr (recnr);     /* Ignore errors for the moment */
  46.             if (errortype)
  47.             {
  48.                 cerr << "Error: " << Message.ErrorType << ", "
  49.                      << Message.ErrorString << ".\n";
  50.                 break;
  51.             }
  52.             cout << "Board: " << Message.Board()
  53.                  << "   Message: " << Message.MsgNum()
  54.                  << "\nBy: " << Message.From()
  55.                  << "\nRe: " << Message.Subject() << "\n\n";
  56.             recnr = Message.NextTo ();
  57.             if (errortype)
  58.             {
  59.                 cerr << "Error: " << Message.ErrorType << ", "
  60.                      << Message.ErrorString << ".\n";
  61.                 break;
  62.             }
  63.         }
  64.         cout << nmsgs << " messages found\n";
  65.  
  66.         cout << "Listing revers...\n";
  67.         recnr = Message.LastTo (&to);
  68.         if (Message.ErrorType)
  69.         {
  70.             cerr << "Error: " << Message.ErrorType << ", "
  71.                  << Message.ErrorString << ".\n";
  72.         }
  73.  
  74.         nmsgs = 0;
  75.         while (recnr != -1)
  76.         {
  77.             nmsgs++;
  78.             Message.ReadHdr (recnr);     /* Ignore errors for the moment */
  79.             if (Message.ErrorType)
  80.             {
  81.                 cerr << "Error: " << Message.ErrorType << ", "
  82.                      << Message.ErrorString << ".\n";
  83.                 break;
  84.             }
  85.             cout << "Board: " << Message.Board()
  86.                  << "   Message: " << Message.MsgNum()
  87.                  << "\nBy: " << Message.From()
  88.                  << "\nRe: " << Message.Subject() << "\n\n";
  89.             recnr = Message.PrevTo ();
  90.             if (Message.ErrorType)
  91.             {
  92.                 cerr << "Error: " << Message.ErrorType << ", "
  93.                      << Message.ErrorString << ".\n";
  94.                 break;
  95.             }
  96.         }
  97.         cout << nmsgs << " messages found\n";
  98.     }
  99.  
  100.     cout << "Done.\n";
  101.     exit (1);
  102. }
  103.